/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.spring.modelo.entidad;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Ricardo
 */
@Entity
@Table(name = "DetallePlan")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "DetallePlan.findAll", query = "SELECT d FROM DetallePlan d"),
    @NamedQuery(name = "DetallePlan.findByCodPlan", query = "SELECT d FROM DetallePlan d WHERE d.detallePlanPK.codPlan = :codPlan"),
    @NamedQuery(name = "DetallePlan.findByCodCurso", query = "SELECT d FROM DetallePlan d WHERE d.detallePlanPK.codCurso = :codCurso")})
public class DetallePlan implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected DetallePlanPK detallePlanPK;
    @JoinColumn(name = "codPlan", referencedColumnName = "codPlan", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Planes planes;
    @JoinColumn(name = "codCurso", referencedColumnName = "codCurso", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Curso curso;
    @JoinColumn(name = "codCiclo", referencedColumnName = "codCiclo")
    @ManyToOne
    private Ciclo codCiclo;

    public DetallePlan() {
    }

    public DetallePlan(DetallePlanPK detallePlanPK) {
        this.detallePlanPK = detallePlanPK;
    }

    public DetallePlan(int codPlan, String codCurso) {
        this.detallePlanPK = new DetallePlanPK(codPlan, codCurso);
    }

    public DetallePlanPK getDetallePlanPK() {
        return detallePlanPK;
    }

    public void setDetallePlanPK(DetallePlanPK detallePlanPK) {
        this.detallePlanPK = detallePlanPK;
    }

    public Planes getPlanes() {
        return planes;
    }

    public void setPlanes(Planes planes) {
        this.planes = planes;
    }

    public Curso getCurso() {
        return curso;
    }

    public void setCurso(Curso curso) {
        this.curso = curso;
    }

    public Ciclo getCodCiclo() {
        return codCiclo;
    }

    public void setCodCiclo(Ciclo codCiclo) {
        this.codCiclo = codCiclo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (detallePlanPK != null ? detallePlanPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DetallePlan)) {
            return false;
        }
        DetallePlan other = (DetallePlan) object;
        if ((this.detallePlanPK == null && other.detallePlanPK != null) || (this.detallePlanPK != null && !this.detallePlanPK.equals(other.detallePlanPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.spring.modelo.entidad.DetallePlan[ detallePlanPK=" + detallePlanPK + " ]";
    }
    
}
